//
//  TeacherCell.m
//  HTP
//
//  Created by admin on 15/11/1.
//  Copyright © 2015年 nit. All rights reserved.
//

#import "TeacherCell.h"
#define TEACHERCELLHEIGHT (ScreenWidth  - 30 - 20)
#define TEACHERCELLWIDTH  (ScreenWidth - 30)
#define PADDING 5
#define BLACKS RGBCOLOR(45, 45, 45, 0.8)
@interface TeacherCell()
@property (nonatomic,strong) UIImageView     *teacherImg;
@property (nonatomic,strong) UILabel         *teacherNameLbl;
@property (nonatomic,strong) UILabel         *priceLbl;
@property (nonatomic,strong) UILabel         *stuCountLbl;
@property (nonatomic,strong) UILabel         *timeLbl;
@property (nonatomic,strong) UILabel         *goodCountLbl;
@end
@implementation TeacherCell
-(void)_initUI{
    
    _teacherImg = [[UIImageView alloc] init];
    [self.contentView addSubview:_teacherImg];
    
    UILabel *rmbLbl     = [[UILabel alloc] init];
    rmbLbl.text         = @"￥";
    rmbLbl.textColor    = [UIColor blackColor];
    rmbLbl.font         = [UIFont systemFontOfSize:14];
    [self.contentView addSubview:rmbLbl];
    [rmbLbl makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(TEACHERCELLHEIGHT - TEACHERCELLHEIGHT/4.0 - TEACHERCELLHEIGHT/4.0/3.0);
        make.right.equalTo(self).offset(-70);
    }];
    
    
    
    UIImageView *lineImage  = [[UIImageView alloc] init];
    lineImage.image         = [UIImage imageNamed:@"DownBg"];
    [self.contentView addSubview:lineImage];
    [lineImage makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(rmbLbl.bottom).offset(10);
        make.left.equalTo(self).offset(50);
        make.right.equalTo(self).offset(-50);
        make.height.equalTo(1);
    }];
    
    _priceLbl = [[UILabel alloc] init];
    _priceLbl.text         = @"150";
    _priceLbl.textColor    = RGBCOLOR(252, 152, 54, 1);
    _priceLbl.font         = [UIFont systemFontOfSize:18];
    [self.contentView addSubview:_priceLbl];
    [_priceLbl makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(lineImage.top).offset(-PADDING * 2);
        make.left.equalTo(rmbLbl.right);
    }];
    
    _teacherNameLbl = [[UILabel alloc] init];
    _teacherNameLbl.text         = @"青苗家教";
    _teacherNameLbl.textColor    = BLACKS;
    _teacherNameLbl.font         = [UIFont fontWithName:@"Helvetica-BoldOblique" size:16];
    [self.contentView addSubview:_teacherNameLbl];
    [_teacherNameLbl makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(lineImage.left).offset(-5);
        make.bottom.equalTo(lineImage.top).offset(-5);
    }];
    UILabel *countLabel = [[UILabel alloc] init];
    countLabel.text     = @"学生人数";
    countLabel.textColor= RGBCOLOR(10, 10, 10, 0.8);
    countLabel.font     = [UIFont systemFontOfSize:15];
    [self.contentView addSubview:countLabel];
    [countLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_teacherNameLbl);
        make.top.equalTo(lineImage.bottom).offset(PADDING);
    }];
    
    _stuCountLbl = [[UILabel alloc] init];
    _stuCountLbl.text     = @"10";
    _stuCountLbl.textColor= [UIColor blackColor];
    _stuCountLbl.font     = [UIFont systemFontOfSize:15];
    [self.contentView addSubview:_stuCountLbl];
    [_stuCountLbl makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(countLabel);
        make.top.equalTo(countLabel.bottom).offset(PADDING * 2.0);
    }];

    
    UILabel *goodLabel = [[UILabel alloc] init];
    goodLabel.text     = @"好评数";
    goodLabel.textColor= RGBCOLOR(10, 10, 10, 0.8);
    goodLabel.font     = [UIFont systemFontOfSize:15];
    [self.contentView addSubview:goodLabel];
    [goodLabel makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(lineImage).offset(PADDING);
        make.right.equalTo (lineImage).offset(PADDING);
    }];
    
    _goodCountLbl = [[UILabel alloc] init];
    _goodCountLbl.text     = @"30";
    _goodCountLbl.textColor= [UIColor blackColor];
    _goodCountLbl.font     = [UIFont systemFontOfSize:15];
    [self.contentView addSubview:_goodCountLbl];
    [_goodCountLbl makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(goodLabel);
        make.top.equalTo(countLabel.bottom).offset(PADDING * 2.0);
    }];
    
    UILabel *timeLabel = [[UILabel alloc] init];
    timeLabel.text     = @"授课时长";
    timeLabel.textColor= RGBCOLOR(10, 10, 10, 0.8);
    timeLabel.font     = [UIFont systemFontOfSize:15];
    [self.contentView addSubview:timeLabel];
    [timeLabel makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(lineImage).offset(PADDING);
        make.centerX.equalTo(self).offset(PADDING);
    }];
    
    _timeLbl = [[UILabel alloc] init];
    _timeLbl.text     = @"300";
    _timeLbl.textColor= [UIColor blackColor];
    _timeLbl.font     = [UIFont systemFontOfSize:15];
    [self.contentView addSubview:_timeLbl];
    [_timeLbl makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(timeLabel);
        make.top.equalTo(countLabel.bottom).offset(PADDING * 2.0);
    }];
    
    UIImageView *good_line  = [[UIImageView alloc] init];
    good_line.image         = [UIImage imageNamed:@"teacher_s"];
    [self.contentView addSubview:good_line];
    [good_line makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(countLabel.bottom).offset(5);
        //        make.left.equalTo(countLabel).offset(50);
        make.left.equalTo(timeLabel.right).offset(15);
        make.height.equalTo(25);
        make.width.equalTo(1);
    }];
    
    UIImageView *count_line  = [[UIImageView alloc] init];
    count_line.image         = [UIImage imageNamed:@"teacher_s"];
    [self.contentView addSubview:count_line];
    [count_line makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(countLabel.bottom).offset(5);
        //        make.left.equalTo(countLabel).offset(50);
        make.right.equalTo(timeLabel.left).offset(-15);
        make.height.equalTo(25);
        make.width.equalTo(1);
    }];

    UIImageView *footImg = [[UIImageView alloc] initWithFrame:CGRectMake(15, TEACHERCELLHEIGHT - TEACHERCELLHEIGHT/4.0 - TEACHERCELLHEIGHT/4.0/3.0 -20, ScreenWidth - 30, TEACHERCELLHEIGHT/4.0 + TEACHERCELLHEIGHT/4.0/3.0 + 20)];
    [footImg setImage:[UIImage imageNamed:@"cardpic"]];
    [self.contentView addSubview:footImg];
    [self.contentView sendSubviewToBack:footImg];
    
    _teacherImg = [[UIImageView alloc] initWithFrame:CGRectMake(15, 0, TEACHERCELLWIDTH, TEACHERCELLHEIGHT - TEACHERCELLHEIGHT/4.0 - TEACHERCELLHEIGHT/4.0/3.0 -20)];
    [_teacherImg setBackgroundColor:[UIColor redColor]];
    [self.contentView addSubview:_teacherImg];
}
-(void)setCellData:(id)cellData{
    _teacher = (TeacherModel *)cellData;
    [_teacherImg setImageWithURL:_teacher.userPhoto andPlaceholder:@""];
    _teacherNameLbl.text = _teacher.userNickName;
    _priceLbl.text = [NSString stringWithFormat:@"等级%@",_teacher.tchLevel];
    _stuCountLbl.text = [NSString stringWithFormat:@"%@",_teacher.sumStu];
    _timeLbl.text = [NSString stringWithFormat:@"%@",_teacher.sumTime];
    _goodCountLbl.text = [NSString stringWithFormat:@"%@",_teacher.tchPraiseCount];
    
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
